package com.ys.tdm.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class DateUtil {
	
	/**
	* 得到本周周一日期
	* @return
	*/
	public static String getWeekMonday(){ 
	SimpleDateFormat formater=new SimpleDateFormat("yyyy-MM-dd");
	Calendar cal=new GregorianCalendar();
	cal.setFirstDayOfWeek(Calendar.MONDAY);
	cal.setTime(new Date());
	cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
	Date first=cal.getTime();
	return formater.format(first);
	}
	/**
	* 得到本周周五日期
	* @return
	*/
	public static String getWeekFriday(){//yyyy-MM-dd
	SimpleDateFormat formater=new SimpleDateFormat("yyyy-MM-dd");
	Calendar cal=new GregorianCalendar();
	        cal.setFirstDayOfWeek(Calendar.MONDAY);
	        cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek() + 4);
	        Date last=cal.getTime();
	        return  formater.format(last);
	}
	/**
	* 获取当月第一天
	* @return
	*/
	public static String getMonthFirstday(){
	SimpleDateFormat formater=new SimpleDateFormat("MM/dd/yyyy");
	Calendar c = Calendar.getInstance();    
	         c.add(Calendar.MONTH, 0);
	         c.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天 
	         String first = formater.format(c.getTime());
	    return first;
	}
}
